Subscribe Us

Responsive Advertisement

Advertisement

1492A Three swimmers codeforces solution in cpp

 

1492A  Three swimmers codeforces solution in cpp

by ujjal roy




#include<bits/stdc++.h>

using namespace std;

main()

{


    unsigned long long int t,p,a,b,c,r1,r2,r3;

    cin>>t;

    while(t--)

    {

        cin>>p>>a>>b>>c;

        if(p%a==0) r1=0;

        else

        {

            r1=a-p%a;

        }


         if(p%b==0) r2=0;

        else

        {

            r2=b-p%b;

        }


         if(p%c==0) r3=0;

        else

        {

            r3=c-p%c;

        }

        cout<<min(r1,min(r2,r3))<<endl;

    }


    return 0;

}



Post a Comment

0 Comments